//https://leetcode.cn/problems/n-ary-tree-level-order-traversal/description/

/*
// Definition for a Node.
class Node {
public:
    int val;
    vector<Node*> children;

    Node() {}

    Node(int _val) {
        val = _val;
    }

    Node(int _val, vector<Node*> _children) {
        val = _val;
        children = _children;
    }
};
*/

class Solution {
public:
    vector<vector<int>> levelOrder(Node* root) {
        if (!root)
        {
            return {};
        }

        vector<vector<int>> vv;
        queue<Node*> q;
        q.push(root);
        while (!q.empty())
        {
            int size = q.size();
            vector<int> v;
            for (size_t i = 0; i < size; i++)
            {
                Node* cur = q.front();
                q.pop();
                v.push_back(cur->val);
                for (size_t j = 0; j < cur->children.size(); j++)
                {
                    q.push(cur->children[j]);
                }
            }
            vv.push_back(v);
        }
        return vv;
    }
};